using System;
using Styx;
using Styx.Common.Helpers;
using Styx.TreeSharp;
using Action = Styx.TreeSharp.Action;

namespace ChiWalker.Spell
{
    public static class WaitFor
    {
        public static int LastCastSpell;
        public static UnitSelectionDelegate LastTarget;

        public static readonly WaitTimer SpellGcd = new WaitTimer(TimeSpan.FromMilliseconds(200));

        public static Composite WaitForCast()
        {
            return
                new Decorator(ret => StyxWoW.Me.IsCasting,
                    new Action(ret => RunStatus.Success));
        }

        public static Composite WaitForCondition(SimpleBooleanDelegate condition)
        {
            return
                new Decorator(ret => condition(ret),
                    new Action(ret => RunStatus.Success));
        }
    }
}